package org.dzq.designmode.composite;

/**
 * @ClassName: Test
 * @Package: org.dzq.designmode.composite
 * @author: 越
 * @date: 2023/6/17 16:43
 * @Description:
 */
public class Test {
    public static void main(String[] args) {
        Component root = new Composite("root");

        Component branchA = new Composite("branchA");
        Component branchB = new Composite("branchB");

        Leaf leafA = new Leaf("leafA");
        Leaf leafB = new Leaf("leafB");
        Leaf leafC = new Leaf("leafC");
        Leaf leafD = new Leaf("leafD");

        root.addChild(branchA);
        root.addChild(branchB);
        root.addChild(leafA);

        branchA.addChild(leafB);
        branchA.addChild(leafC);
        branchB.addChild(leafD);

        root.printTree();
        branchA.printTree();
    }
}
